package com.zz.springboot.manager.impl;

import com.zz.springboot.anno.ImportExcelMark;
import com.zz.springboot.dto.DataDTO;
import com.zz.springboot.manager.XiangGangManager;
import com.zz.springboot.mapper.XiangGangMapper;
import com.zz.springboot.model.ExcludeInfo;
import com.zz.springboot.model.XiangGang;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

@Service
public class XiangGangManagerImpl implements XiangGangManager {

    @Autowired
    XiangGangMapper xiangGangMapper;

    @Override
    public List<Integer> selectAllNums() {
        List<Integer> numSet = xiangGangMapper.selectAllNums();
        if (CollectionUtils.isEmpty(numSet)) {
            numSet = new ArrayList<>();
        }
        return numSet;
    }

    @Override
    public List<DataDTO> selectAllData() {
        List<DataDTO> allData = xiangGangMapper.selectAllData();
        if (CollectionUtils.isEmpty(allData)) {
            allData = new ArrayList<>();

        }
        return allData;
    }

    @Override
    @ImportExcelMark
    public Integer insertBatchData(List<DataDTO> dataDTOList) {
        return xiangGangMapper.insertData(dataDTOList);
    }

    @Override
    //@ImportExcelMark
    public Integer insertXiangGangData(List<XiangGang> dataList) {
        return xiangGangMapper.insertXiangGangData(dataList);
    }

    @Override
    public void updateBatchData(List<DataDTO> dataDTOList) {
        xiangGangMapper.updateBatchData(dataDTOList);

    }

    @Override
    public List<ExcludeInfo> getAllExcludeInfo() {
        List<ExcludeInfo> allExcludeInfo = xiangGangMapper.getAllExcludeInfo();
        if (CollectionUtils.isEmpty(allExcludeInfo)) {
            allExcludeInfo = new ArrayList<>();
        }
        return allExcludeInfo;
    }


    public void clearTable() {
        xiangGangMapper.clearXiangGangTable();
    }

    @Override
    public List<DataDTO> selectOddsOrEvensData(String category) {
        List<DataDTO> data = xiangGangMapper.selectOddsOrEvensData(category);

        return data == null ? new ArrayList<>() : data;
    }

    @Override
    public List<DataDTO> selectBigLittle(String category) {
        List<DataDTO> data = xiangGangMapper.selectBigLittleData(category);
        return data == null ? new ArrayList<>() : data;
    }

    @Override
    public List<DataDTO> selectColorData(String category) {
        List<DataDTO> data = xiangGangMapper.selectColorData(category);
        return data == null ? new ArrayList<>() : data;
    }

    @Override
    public List<DataDTO> selectAnimalsData(String category) {
        List<DataDTO> data = xiangGangMapper.selectAnimalsData(category);
        return data == null ? new ArrayList<>() : data;
    }

    @Override
    public List<DataDTO> selectTailData(String category) {
        List<DataDTO> data = xiangGangMapper.selectTailData(category);
        return data == null ? new ArrayList<>() : data;
    }
}
